/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 * Copyright (C) 2019 XiaoMi, Inc.
 * Copyright (C) 2018-2010 The LineageOS Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <dt-bindings/msm/power-on.h>

// msm-audio.dtsi
&int_codec {
	/delete-property/ qcom,us-euro-gpios;
};

// msm-pm660.dtsi
&spmi_bus {
	qcom,pm660@0 {
		qcom,power-on@800 {
			qcom,pon-dbc-delay = <62500>;
			qcom,pon_1 {
				qcom,support-reset = <1>;
				qcom,s1-timer = <6720>;
				qcom,s2-timer = <2000>;
				qcom,s2-type = <PON_POWER_OFF_HARD_RESET>;
			};

			qcom,pon_3 {
				qcom,pon-type = <3>;
				qcom,support-reset = <1>;
				qcom,pull-up = <1>;
				qcom,s1-timer = <1352>;
				qcom,s2-timer = <2000>;
				qcom,s2-type = <PON_POWER_OFF_WARM_RESET>;
				qcom,use-bark;
			};
		};
	};
};

&pm660_rtc {
	qcom,qpnp-rtc-alarm-pwrup = <1>;
};

&pm660_fg {
	qcom,hold-soc-while-full;
};

&pm660_haptics {
	/delete-property/ qcom,correct-lra-drive-freq;
};

// msm-pm660l.dtsi
&pm660l_torch0 {
	qcom,max-current = <100>;
	qcom,current-ma = <100>;
};

&pm660l_torch1 {
	qcom,max-current = <100>;
	qcom,current-ma = <100>;
};

&pm660l_torch2 {
	qcom,max-current = <60>;
	qcom,current-ma = <60>;
};

// sdm660-audio.dtsi
&wsa881x_213_en {
	qcom,spkr-sd-n-node = <&wsa_spkr_en2>;
};

&wsa881x_214_en {
	qcom,spkr-sd-n-node = <&wsa_spkr_en1>;
};

// sdm660-camera.dtsi
&i2c_freq_100Khz {
	qcom,hw-scl-stretch-en = <1>;
};

&i2c_freq_400Khz {
	qcom,hw-scl-stretch-en = <1>;
};

&i2c_freq_1Mhz {
	qcom,hw-scl-stretch-en = <1>;
};

// sdm660-mdss.dtsi
&mdss_mdp {
	qcom,mdss-ib-factor = <105 100>;        /* 1.05 times */
};

// sdm660-pinctrl.dtsi
&i2c_4_sleep {
	config {
		/delete-property/ bias-pull-up;
		bias-disable;
	};
};

&spi_8_sleep {
	config {
		/delete-property/ bias-disable;
		bias-pull-down;
	};
};

&tlmm {
	sec_mi2s {
		sec_mi2s_sleep: sec_mi2s_sleep {
			mux {
				pins = "gpio24", "gpio25";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio24", "gpio25";
				drive-strength = <2>;   /* 2 mA */
				bias-disable;         /* NO PULL */
				output-low;
			};
		};
		sec_mi2s_active: sec_mi2s_active {
			mux {
				pins = "gpio24", "gpio25";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio24", "gpio25";
				drive-strength = <8>;   /* 8 mA */
				bias-disable;           /* NO PULL */
				output-high;
			};
		};
	};

	sec_mi2s_sd0 {
		sec_mi2s_sd0_sleep: sec_mi2s_sd0_sleep {
			mux {
				pins = "gpio26";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio26";
				drive-strength = <2>;   /* 2 mA */
				bias-pull-down;         /* PULL DOWN */
				output-low;
			};
		};
		sec_mi2s_sd0_active: sec_mi2s_sd0_active {
			mux {
				pins = "gpio26";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio26";
				drive-strength = <8>;  /* 8 mA */
				bias-disable;           /* NO PULL */
				output-high;
			};
		};
	};

	sec_mi2s_sd1 {
		sec_mi2s_sd1_sleep: sec_mi2s_sd1_sleep {
			mux {
				pins = "gpio27";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio27";
				drive-strength = <2>;   /* 2 mA */
				bias-pull-down;         /* PULL DOWN */
				input-enable;
			};
		};
		sec_mi2s_sd1_active: sec_mi2s_sd1_active {
			mux {
				pins = "gpio27";
				function = "sec_mi2s";
			};
			config {
				pins = "gpio27";
				drive-strength = <8>;   /* 8 mA */
				bias-disable;           /* NO PULL */
				input-enable;
			};
		};
	};
};

&wcd_gnd_mic_swap_idle {
	mux {
		pins = "gpio56";
	};
	config {
		pins = "gpio56";
		/delete-property/ bias-pull-down;
		/delete-property/ output-low;
		bias-disable;
		input-enable;
	};
};

&wcd_gnd_mic_swap_active {
	mux {
		pins = "gpio56";
	};
	config {
		pins = "gpio56";
	};
};

&cci0_suspend {
	config {
		/delete-property/ bias-pull-down;
		bias-disable; /* NO PULL */
	};
};

&cci1_suspend {
	config {
		/delete-property/ bias-pull-down;
		bias-disable; /* NO PULL */
	};
};

&tlmm {
	cam_sensor_mclk0_platina_active: cam_sensor_mclk0_platina_active {
		/* MCLK0 */
		mux {
			/* CLK */
			pins = "gpio32";
			function = "cam_mclk";
		};

		config {
			pins = "gpio32";
			bias-disable; /* No PULL */
			drive-strength = <4>; /* 4 MA */
		};
	};

	cam_sensor_mclk0_platina_suspend: cam_sensor_mclk0_platina_suspend {
		/* MCLK0 */
		mux {
			/* CLK */
			pins = "gpio32";
			function = "cam_mclk";
		};

		config {
			pins = "gpio32";
			bias-pull-down; /* PULL DOWN */
			drive-strength = <4>; /* 4 MA */
		};
	};

	cam_sensor_mclk0_active_jason: cam_sensor_mclk0_active_jason {
		/* MCLK0 */
		mux {
			/* CLK */
			pins = "gpio32";
			function = "cam_mclk";
		};

		config {
			pins = "gpio32";
			bias-disable; /* No PULL */
			drive-strength = <4>; /* 2 MA */
		};
	};

	cam_sensor_mclk0_suspend_jason: cam_sensor_mclk0_suspend_jason {
		/* MCLK0 */
		mux {
			/* CLK */
			pins = "gpio32";
			function = "cam_mclk";
		};

		config {
			pins = "gpio32";
			bias-pull-down; /* PULL DOWN */
			drive-strength = <4>; /* 2 MA */
		};
	};

	cam_sensor_mclk1_platina_active: cam_sensor_mclk1_platina_active {
		/* MCLK1 */
		mux {
			/* CLK */
			pins = "gpio33";
			function = "cam_mclk";
		};

		config {
			pins = "gpio33";
			bias-disable; /* No PULL */
			drive-strength = <4>; /* 4 MA */
		};
	};

	cam_sensor_mclk1_platina_suspend: cam_sensor_mclk1_platina_suspend {
		/* MCLK1 */
		mux {
			/* CLK */
			pins = "gpio33";
			function = "cam_mclk";
		};

		config {
			pins = "gpio33";
			bias-pull-down; /* PULL DOWN */
			drive-strength = <4>; /* 4 MA */
		};
	};

	cam_sensor_front_active_jason: cam_sensor_front_active_jason {
		/* RESET  VANA*/
		mux {
			pins = "gpio47", "gpio44", "gpio49";
			function = "gpio";
		};

		config {
			pins = "gpio47", "gpio44", "gpio49";
			bias-disable; /* No PULL */
			drive-strength = <2>; /* 2 MA */
		};
	};

	cam_sensor_mclk3_platina_active: cam_sensor_mclk3_platina_active {
		/* MCLK3 */
		mux {
			/* CLK */
			pins = "gpio35";
			function = "cam_mclk";
		};

		config {
			pins = "gpio35";
			bias-disable; /* No PULL */
			drive-strength = <4>; /* 4 MA */
		};
	};

	cam_sensor_mclk3_platina_suspend: cam_sensor_mclk3_platina_suspend {
		/* MCLK3 */
		mux {
			/* CLK */
			pins = "gpio35";
			function = "cam_mclk";
		};

		config {
			pins = "gpio35";
			bias-pull-down; /* PULL DOWN */
			drive-strength = <4>; /* 4 MA */
		};
	};

	spk_id_no_pull: spk_id_no_pull {
		mux {
			pins = "gpio113";
			function = "gpio";
		};
		config {
			pins = "gpio113";
			drive-strength = <8>;
			bias-disable;
			input-enable;
		};
	};

	spk_id_pull_up: spk_id_pull_up {
		mux {
			pins = "gpio113";
			function = "gpio";
		};
		config {
			pins = "gpio113";
			drive-strength = <8>;
			bias-pull-up;
			input-enable;
		};
	};

	spk_id_pull_down: spk_id_pull_down {
		mux {
			pins = "gpio113";
			function = "gpio";
		};
		config {
			pins = "gpio113";
			drive-strength = <8>;
			bias-pull-down;
			input-enable;
		};
	};
};

// sdm660-pm.dtsi
&soc {
	qcom,mpm@7781b8 {
		qcom,gpio-map =
			<3  1>,
			<4  5>,
			<5  9>,
			<6  10>,
			<7  66>,
			<8  22>,
			<9  25>,
			<10  28>,
			<11  58>,
			<13  41>,
			<14  43>,
			<15  40>,
			<16  42>,
			<17  46>,
			<18  50>,
			<19  44>,
			<21  56>,
			<22  45>,
			<23  68>,
			<24  69>,
			<25  70>,
			<26  71>,
			<27  72>,
			<28  73>,
			<29  64>,
			<30  2>,
			<31  13>,
			<32  111>,
			<33  74>,
			<34  75>,
			<35  76>,
			<36  82>,
			<37  17>,
			<38  77>,
			<39  47>,
			<40  54>,
			<41  48>,
			<42  101>,
			<43  49>,
			<44  51>,
			<45  86>,
			<46  90>,
			<47  91>,
			<48  52>,
			<50  55>,
			<51  6>,
			<53  65>,
			<55  67>,
			<56  83>,
			<57  84>,
			<58  85>,
			<59  87>,
			<63  21>,
			<64  78>,
			<65  113>,
			<66  60>,
			<67  98>,
			<68  30>,
			<70  31>,
			<71  29>,
			<76  107>,
			<83  109>,
			<84  103>,
			<85  105>,
			<0xff  59>;
	};
};

// sdm660-regulator.dtsi
&soc {
	/* panel 1.8v power*/
	disp_vdd_vreg: disp_vdd_vreg {
		compatible = "regulator-fixed";
		regulator-name = "disp_vdd_vreg";
		startup-delay-us = <4000>;
		enable-active-high;
		regulator-boot-on;
	};
};

// sdm660.dtsi
&adsp_fw_mem {
	reg = <0x0 0x92a00000 0x0 0x2200000>;
};

&pil_mba_mem {
	reg = <0x0 0x94c00000 0x0 0x200000>;
};

&cdsp_fw_mem {
	reg = <0x0 0x94e00000 0x0 0x600000>;
};

&wdog {
	qcom,bark-time = <20000>;
	qcom,pet-time = <15000>;
};

&sensor_information15 {
	qcom,sensor-name = "cam_therm0";
};

&soc {
	qcom,sensor-information {
		sensor_information22: qcom,sensor-information-22 {
			qcom,sensor-type =  "adc";
			qcom,sensor-name = "cam_therm1";
		};
		sensor_information23: qcom,sensor-information-23 {
			qcom,sensor-type =  "adc";
			qcom,sensor-name = "backlight_therm";
		};
	};

	qcom,bcl {
		qcom,ibat-monitor {
			qcom,soc-low-threshold = <5>;
		};
	};
};

&qcom_seecom {
	/delete-property/ qcom,fde-key-size;
	/delete-property/ qcom,qsee-reentrancy-support;
};

&soc {
	gpio_keys {
		/delete-property/ pinctrl-names;
		/delete-property/ pinctrl-0;
		/delete-property/ pinctrl-1;

		/delete-node/ camera_focus;
		/delete-node/ camera_snapshot;
	};
};

// custom
/ {
	reserved-memory {
		ramoops_mem: ramoops_region@b0000000 {
			compatible = "removed-dma-pool";
			no-map;
			reg = <0 0xb0000000 0 0x400000>;
		};
	};
};

&soc {
	ramoops {
		compatible = "ramoops";
		memory-region = <&ramoops_mem>;
		console-size = <0x0 0x200000>;
		pmsg-size = <0x0 0x200000>;
	};
};
